//
//  StatusRetweetView.swift
//  SinaWeibo25
//
//  Created by apple on 16/3/16.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit
class StatusRetweetView: UIView {
    
    var retweetedstatus: Status? {
        didSet {
            retweetedLabel.text = retweetedstatus?.text
            picture.imageURLs = retweetedstatus?.imageURls
        }
    }
    
//    重构
    override init(frame: CGRect) {
        super.init(frame: frame)
       setUI()
    }
//默认报错
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    MARK: 设置UI
    private func setUI() {
        
        addSubview(retweetedLabel)
        
        addSubview(picture)
        //设置约束
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.left.top.equalTo(self).offset(StatusCellMargin)
            make.right.equalTo(self.snp_right).offset(-StatusCellMargin)
        }
        
        picture.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedLabel.snp_left)
            make.top.equalTo(retweetedLabel.snp_bottom).offset(StatusCellMargin)
            make.size.equalTo(CGSize(width: 100, height: 100))
        }
        
        //给转发微博的底部添加约束
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(picture.snp_bottom).offset(StatusCellMargin)
        }
    
    }
    
    private lazy var retweetedLabel: UILabel = UIFactory.labelFactory("寒假快乐法国官方的说法", textColor: UIColor.darkGrayColor(), fontSize: 15, alignment: .Left)
    private lazy var picture: Statuspicture = Statuspicture()
}
